package org.i_plus.model.services;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.i_plus.TestDaily;
import org.i_plus.model.ConstellationBean;
import org.i_plus.model.dao.ConstellationDAO;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ConstellationService {
	
	private ConstellationDAO dao ;
	private TestDaily daily;
	public ConstellationService(ConstellationDAO dao){
		this.dao=dao;
	}
	public List<ConstellationBean> selectAll(){
		List<ConstellationBean> list = dao.selectAll();
		
		return list;
	}
	
	public void setTestDaily(TestDaily daily){
		this.daily=daily;
	}
	
	public ConstellationBean selectbyName(ConstellationBean bean){
		ConstellationBean result= null;
		if(bean!=null){
			result= dao.select(bean.getName());
		}
		return result ;
	}
	
	public void update(ConstellationBean bean){
		if(bean!=null){
			dao.update(bean.getName(), bean.getPic(), bean.getIntro(), bean.getMind_star(), bean.getMoney_star(), bean.getHealth_star(), bean.getLuck_dir(), bean.getLove_star(), bean.getWork_star(), bean.getLuck_color(), bean.getLuck_thing(), bean.getMind_word(), bean.getLove_word(), bean.getMoney_word(), bean.getWork_word());	
		}
	}
	public static void main (String[] args){
		ApplicationContext context =
				new ClassPathXmlApplicationContext("beans.config.xml");
		SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory");
		Session session=sessionFactory.getCurrentSession();
		session.beginTransaction();
		
		ConstellationService service = (ConstellationService) context.getBean("constellationService");
		
	}
}
